VtOptionMenu


Create an OptionMenu widget

Syntax

VtOptionMenu object_name [options]

Description

Creates an OptionMenu widget which is a menu system component that lets a user select one of several choices. Returns the OptionMenu widget's name.

OptionMenus are created like Pulldown menus: first the OptionMenu is created and then it is "filled" in with other widgets. (The Label class options are supported, so that the OptionMenus can be titled.)

Callbacks can be assigned to the individual widgets which make up the OptionMenu, or a callback can be assigned to the OptionMenu itself. If this is done, callbacks assigned to the OptionMenu children will be overridden and the OptionMenu callback will be called if any of the children are activated. The child which caused the callback to be called will be passed as callback data.

Options

-callback cmd (C)
Specifies the callback cmd as the routine to call when any of the options are activated (by <Space>, <Enter>, or a single mouse click). This callback overrides any activation callbacks assigned to children of the OptionMenu.

Additional Callback keys

(selectedWidget
The name of the widget that activated this callback)

value
The name of the widget that activated this callback

-selectedWidget object_name (SG)
Specifies the name of the widget that is selected in the OptionMenu.

Example

The following code produces an OptionMenu with the options apple, orange, and kumquat:

set app [VtOpen "VtOptionMenu Demo"]
set form [VtForm $app.form]

set menu [VtOptionMenu $form.menu -label "Pick one:"
set but1 [VtPushButton $menu.but1 -label apple]
set but2 [VtPushButton $menu.but2 -label orange]
set but3 [VtPushButton $menu.but3 -label kumquat]

VtShowDialog $app.form
VtMainLoop

This code produces the following:

See also: